package cn.com.xinjinfu.pdoulcProduct.engine;

import java.util.Map;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.widget.Button;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

import cn.com.xinjinfu.pdoulcProduct.manager.ToastManager;
/**
 *
 */
public class ComAsk {
	public static final int Success = 200;
	public static final int Error = 400;

	/**
	 * 获取手机验证码
	 * 返回正确 才会执行handler
	 */
	public static void getVerifyCode(String mobile ,final Context context,final Button bn,String type) {
		bn.setEnabled(false);
		RequestQueue requen = Volley.newRequestQueue(context);
		Map<String, String> mp = DataHandler.getNewParameters("1411");
		mp.put("type", type);
		mp.put("mobile", mobile);
		Handler hand = new Handler(){
			public void handleMessage(Message msg) {
				if(msg.what == ComAsk.Success){      //200
					ToastManager.showShort(context,"短信验证码发送成功");
					ButtonsCd cds = new ButtonsCd(60000, 1000, bn);
					cds.start();
				}else
					bn.setEnabled(true);
			}
		};
		DataHandler.sendRequest(requen, mp, context, hand, false, true,true);
	}

}
